package org.homonoia.model.query;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;

import org.homonoia.model.core.Row;
import org.homonoia.model.task.TaskResults;

public class QueryResults implements Serializable {

    private static final long serialVersionUID = 586713175602934078L;
    private int rowIndex = 0;
    private ArrayList<Row> rowList = null;

    public QueryResults() {
	super();

	rowIndex = 0;
	rowList = new ArrayList<Row>();
    }

    public void appendTaskResults(final TaskResults res) {
	rowList.addAll(res.getResultSet());
    }

    public boolean hasMore() {
	return rowIndex < rowList.size();
    }

    public final Row current() {
	return rowList.get(rowIndex);
    }

    public void moveNext() {
	rowIndex++;
    }

    private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException {
	is.defaultReadObject();
    }

    private void writeObject(ObjectOutputStream os) throws IOException {
	os.defaultWriteObject();
    }
}
